package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {


    @Autowired
    private BaiduService baiduService;

    /*
     *  上报地理信息
     *    请求方式和请求链接 : POST  /location
     *    请求参数: Body latitude,longitude,-Double  addrStr -string
     *    返回值:  无
     * */

    @PostMapping("/location")
    public ResponseEntity location(@RequestBody Map map) {

        Double latitude = (Double) map.get("latitude");
        Double longitude = (Double) map.get("longitude");
        String addrStr = (String) map.get("addrStr");

        baiduService.location(latitude,longitude,addrStr);

        return ResponseEntity.ok(null);
    }
}
